package com.xbongbong.paas.enums;

import com.xbongbong.i18n.util.I18nMessageUtil;

/**
 * @author: wufeng
 * @date: 2018/9/11 15:03
 * @desrcption:
 */
public enum WebScreenFieldTypeEnum {


    // 分割线：separator
    SEPARATOR(10002, "separator", "basic", "enum.webScreenFieldType.description.separator"),
    // 图片image
    IMAGE(6, "image", "basic", "enum.webScreenFieldType.description.image"),
    // 附件 upload
    UPLOAD(8, "upload", "basic", "enum.webScreenFieldType.description.upload"),
    // 描述文本
    MEMO(10004, "memo", "basic", "enum.webScreenFieldType.description.memo"),
    // 超链接
    HREF(10005, "href", "basic", "enum.webScreenFieldType.description.href"),
    // address 地址
//    ADDRESS(12, "address", "basic", "地址"),
    // location定位
    LOCATION(10003, "location", "basic", "enum.webScreenFieldType.description.location"),
    // 子表单 subform
    SUBFORM(10006, "subform", "complex", "enum.webScreenFieldType.description.subform"),
    // 关联查询 linkquery
    LINKQUERY(10007, "linkquery", "complex", "enum.webScreenFieldType.description.linkquery"),
    // 服务项目
    SELECT_SERVICE(FieldTypeEnum.SELECT_SERVICE.getType(), FieldTypeEnum.SELECT_SERVICE.getAlias(), FieldTypeEnum.SELECT_SERVICE.getBelong(), FieldTypeEnum.SELECT_SERVICE.getDescription()),
    // 关联数据 linkdata
    //LINKDATA(10008, "linkdata", "complex", "关联数据"),
    // 创建人
//    CREATORID(10013, "creatorId", "system", "创建人"),
//    // 创建时间
//    ADDTIME(10014, "addTime", "system", "创建时间"),
//    // 修改时间
//    UPDATETIME(10015, "updateTime", "system", "修改时间"),
    // 所属部门
//    DEPARTMENTID(10016, "departmentId", "system", "所属部门"),
    // 拥有者
//    OWNERID(10017, "ownerId", "system", "拥有者"),
    // Synergetic协同人
//    COUSERID(10018, "coUserId", "system", "协同人"),
    // serial number 流水号
//    SERIALNO(10019, "serialNo", "system", "流水号"),
    ;

    /**
     * 字段类型
     */
    private Integer type;
    /**
     * 字段类型英文
     */
    private String alias;
    /**
     * 字段所属
     */
    private String belong;

    /**
     * 字段描述
     */
    private String description;

    WebScreenFieldTypeEnum(Integer type, String alias, String belong, String description){
        this.type = type;
        this.alias = alias;
        this.belong = belong;
        this.description = description;
    }

    public static WebScreenFieldTypeEnum getByCode(Integer type) {
        for (WebScreenFieldTypeEnum e: values()) {
            if(type.equals(e.getType())){
                return e;
            }
        }
        return null;
    }

    public static boolean isHasNeedFilterField(Integer type) {
        for (WebScreenFieldTypeEnum e: values()) {
            if(type.equals(e.getType())){
                return true;
            }
        }
        return false;
    }

    public Integer getType() {
        return type;
    }

    public void setType(Integer type) {
        this.type = type;
    }

    public String getAlias() {
        return alias;
    }

    public void setAlias(String alias) {
        this.alias = alias;
    }

    public String getBelong() {
        return belong;
    }

    public void setBelong(String belong) {
        this.belong = belong;
    }

    public String getDescription() {
        return I18nMessageUtil.getMessage(description);
    }

    public void setDescription(String description) {
        this.description = description;
    }
}
